import { Http } from '@/common/api'

/**
 * 保存基本信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddBase = async (param) => Http.post('/srm/supplier/add', param)

/**
 * 修改基本信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateBase = async (param) => Http.put('/srm/supplier/update', param)

/**
 * 查询基本信息
 * @param id
 * @return {*|Promise}
 */
export const apiGetBase = async (id) => Http.get(`/srm/supplier/findById/${id}`)

/**
 * 保存法人信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddCorporation = async (param) => Http.post('/srm/supplier/corporation/add', param)

/**
 * 修改法人信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateCorporation = async (param) => Http.put('/srm/supplier/corporation/update', param)
/**
 * 查询法人信息
 * @param id
 * @return {*|Promise}
 */
export const apiGetCorporation = async (supplierId) =>
  Http.get(`/srm/supplier/corporation/findBySupplierId/${supplierId}`)

/**
 * 保存代表人信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddLiaison = async (param) => Http.post('/srm/supplier/liaison/add', param)

/**
 * 修改代表人信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateLiaison = async (param) => Http.put('/srm/supplier/liaison/update', param)

/**
 * 查询代表人信息
 * @param id
 * @return {*|Promise}
 */
export const apiGetLiaison = async (supplierId) => Http.get(`/srm/supplier/liaison/findBySupplierId/${supplierId}`)

/**
 * 保存股本结构信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddCapital = async (param) => Http.post('/srm/supplier/capital/add', param)

/**
 * 修改股本结构信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateCapital = async (param) => Http.put('/srm/supplier/capital/update', param)

/**
 * 查询股本结构信息
 * @param id
 * @return {*|Promise}
 */
export const apiGetCapital = async (supplierId) => Http.get(`/srm/supplier/capital/findBySupplierId/${supplierId}`)

/**
 * 保存发票信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddInvoice = async (param) => Http.post('/srm/supplier/invoice/add', param)

/**
 * 修改发票信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateInvoice = async (param) => Http.put('/srm/supplier/invoice/update', param)

/**
 * 查询发票信息
 * @param id
 * @return {*|Promise}
 */
export const apiGetInvoice = async (supplierId) => Http.get(`/srm/supplier/invoice/findBySupplierId/${supplierId}`)

/**
 * 保存银行信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddBank = async (param) => Http.post('/srm/supplier/bank/add', param)

/**
 * 修改银行信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateBank = async (param) => Http.put('/srm/supplier/bank/update', param)

/**
 * 查询银行信息
 * @param id
 * @return {*|Promise}
 */
export const apiGetBank = async (supplierId) => Http.get(`/srm/supplier/bank/findById/${supplierId}`)

/**
 * 人员信息
 * @param id
 * @return {*|Promise}
 */
// 列表
export const apiPostStaffPageApi = '/srm/supplier/staff/page'
// 新增
export const apiPostStaffAdd = async (data) => Http.post('/srm/supplier/staff/add', data)
export const apiPutStaffUpdate = async (parmas) => Http.put('/srm/supplier/staff/update', parmas)
export const apiDeleteStaffDelete = async (id) => Http.delete(`/srm/supplier/staff/delete?id=${id}`)
export const apiGetStaffFindById = async (id) => Http.get(`/srm/supplier/staff/findById/${id}`)

export const listUrl = '/srm/supplier/page'

// 删除供应商
export const apiDeleteSupplier = async (supplierId) => Http.delete(`/srm/supplier/delete?id=${supplierId}`)

/**
 * 批量启用
 * @param params
 * @return {*|Promise}
 */
export const apiPutEnableSupplier = async (supplierId) => Http.put(`/srm/supplier/enable?id=${supplierId}`)

/**
 * 批量停用
 * @param params
 * @return {*|Promise}
 */
export const apiPutDisableSupplier = async (supplierId) => Http.put(`/srm/supplier/disable?id=${supplierId}`)

/**
 *  保存准入信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostAddAdmittance = async (param) => Http.post('/srm/supplier/admittance/add', param)

/**
 * 修改准入信息
 * @param param
 * @return {*|Promise}
 */
export const apiPostUpdateAdmittance = async (param) => Http.put('/srm/supplier/admittance/update', param)

// 查询准入信息
export const apiGetSupplierAdmittance = async (supplierId) =>
  Http.get(`/srm/supplier/admittance/findBySupplierId/${supplierId}`)

/**
 * 查询物料类型树
 * @param params
 * @return {*|Promise}
 */
export const apiMaterialTypeTree = async (params) => Http.post('/srm/materialType/tree', params)

/**
 * 查询物料类型树
 * @param params
 * @return {*|Promise}
 */
export const apiSupplierRankList = async () => Http.post('/srm/rank/list')

/**
 * 行业分类 字典树
 * @param params
 * @return {*|Promise}
 */
export const apiSupplierFindTree = async (params) => Http.post('/srm/dict/tree/findTree', params)

// 保存档案
export const apiGetSupplierArchives = async (id) => Http.get(`/srm/supplier/archives?id=${id}`)

// 主供服务类型
export const apiPostGetServiceType = async (params) => Http.post('/srm/type/tree', params)

// 主供服务类型
export const apiPostAreaTree = async (params) => Http.post('/upms/area/tree', params)
